package com.duoduo.system.service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.core.userdetails.UsernameNotFoundException;

import com.duoduo.system.dao.UserDao;
import com.duoduo.system.model.User;

public class UserService implements UserDetailsService {

	@Autowired
	private UserDao userDao;

	@Override
	public UserDetails loadUserByUsername(String account) throws UsernameNotFoundException {
		User user = userDao.getByAccount(account);
		if (user == null) {
			throw new UsernameNotFoundException("用户名不存在");
		}
		return user;
	}
}
